<template>
	<view class="transfer-manage">
		<titleName :name="name"></titleName>
		<view class="title-bgc"></view>
		<view class="content-wrap">
			<image class="img" src="../../static/transfer-manage-icon.png" mode=""></image>
			<view class="data-content">
				<view class="bgc">
					<view class="num">
						<view class="name">联单数量</view>
						<view class="val">2000</view>
					</view>
					<view class="pre-accepted">
						<view class="name">待接收</view>
						<view class="val">800</view>
					</view>
					<view class="already-received">
						<view class="name">已签收</view>
						<view class="val">200</view>
					</view>
				</view>
			</view>
			<view class="kupono-confirm" @click="jumpKuponoConfirm">
				<image class="icon" src="../../static/liandanqueren.png" mode=""></image>
				<text>联单创建确认</text>
				<image class="arrow"
					src="https://splendid.oss-cn-beijing.aliyuncs.com/static/imghazardouswaste/right-arrow.png" mode="">
				</image>
			</view>
			<view class="no-sign" @click="jumpNoSign">
				<image class="icon" src="../../static/daiqianshou.png" mode=""></image>
				<text>待签收联单</text>
				<image class="arrow"
					src="https://splendid.oss-cn-beijing.aliyuncs.com/static/imghazardouswaste/right-arrow.png" mode="">
				</image>
			</view>
			<view class="sign-for" @click="jumpSignFor">
				<image class="icon" src="../../static/yiqianshou.png" mode=""></image>
				<text>已签收联单</text>
				<image class="arrow"
					src="https://splendid.oss-cn-beijing.aliyuncs.com/static/imghazardouswaste/right-arrow.png" mode="">
				</image>
			</view>
		</view>



	</view>
</template>
<!-- range.supportdepartmentid -->
<script setup>
	import titleName from '../../components/titleName.vue'
	import http from '../../request/index'
	import {
		ref,
		computed,
		reactive
	} from 'vue'
	let name = "转移联单"
	let enterpriseDetail = ref({})
	let district = ref('')

	let departmentname = ref('')
	let licenseStyle = reactive({})
	let authStyle = reactive({})
	let searchImage = (url) => {
		uni.previewImage({
			urls: [url],
			current: 0
		})
	}
	let computedlicenseStyle = computed(() => {

		return {
			width: licenseStyle.width,
			height: licenseStyle.height

		}

	})
	let computedAuthStyle = computed(() => {
		return {
			width: authStyle.width,
			height: authStyle.height

		}
	})

	let findId = function(data) {

		let id = enterpriseDetail.value.district
		let res = data.map((item) => {
			if (item.id == id) {

				district.value = item.regionname
				return
			}
			if (item.lstSubNodes && item.lstSubNodes.length > 0) {
				return findId(item.lstSubNodes)
			}
		})

	}

	http({
		url: '/enterprise/detail'
	}).then((res) => {
		if (res.code == 0) {
			enterpriseDetail.value = res.data

			uni.getImageInfo({
				src: enterpriseDetail.value.dischargelicenseurl,
				success: function(imageInfoRes) {

					const MAX_WIDTH = 600;
					const MAX_HEIGHT = 800;
					let ratio;

					if (imageInfoRes.width > imageInfoRes.height) {
						ratio = MAX_WIDTH / imageInfoRes.width
					} else {
						ratio = MAX_HEIGHT / imageInfoRes.height
					}

					const scale = Math.min(ratio, 1); // 确保不会超过原始尺寸
					const newWidth = imageInfoRes.width * scale;
					const newHeight = imageInfoRes.height * scale;


					licenseStyle.width = newWidth + 'rpx'
					licenseStyle.height = newHeight + 'rpx'


				}
			});



			uni.getImageInfo({
				src: enterpriseDetail.value.authbookurl,
				success: function(imageInfoRes) {

					const MAX_WIDTH = 600;
					const MAX_HEIGHT = 800;
					let ratio;

					if (imageInfoRes.width > imageInfoRes.height) {
						ratio = MAX_WIDTH / imageInfoRes.width
					} else {
						ratio = MAX_HEIGHT / imageInfoRes.height
					}

					const scale = Math.min(ratio, 1); // 确保不会超过原始尺寸
					const newWidth = imageInfoRes.width * scale;
					const newHeight = imageInfoRes.height * scale;
					authStyle.width = newWidth + 'rpx'
					authStyle.height = newHeight + 'rpx'



				}
			});



		}
	})
	let jumpKuponoConfirm = () => {
		uni.navigateTo({
			url: '/operationUnitPageOhter/kuponoconfirm/kuponoconfirm'
		})
	}
	let jumpNoSign = () => {
		uni.navigateTo({
			url: '/operationUnitPageOhter/nosign/nosign'
		})
	}
	let jumpSignFor = ()=>{
		uni.navigateTo({
			url: '/operationUnitPageOhter/signfor/signfor'
		})
	}
	http({
		url: '/region/datalisttree'
	}).then((res) => {
		let data = res.data
		findId(data)
	})
	http({
		url: '/listitem/getdepartment'
	}).then((res) => {
		if (res.code == 0) {
			let arr = res.data
			let result = arr.find((item) => {
				if (item.id == enterpriseDetail.value.supportdepartmentid) {
					departmentname.value = item.departmentname
					return item
				}

			})
			console.log(result, 'retuls');
		}

	})
</script>

<style lang="scss" scoped>
	.transfer-manage {
		width: 100vw;
		height: 100vh;
		padding-top: 160rpx;

		.title-bgc {
			background: #0874FA;
			height: 160rpx;
			width: 100vw;
			position: fixed;
			top: 0%;
			left: 0;

		}

		.content-wrap {
			height: calc(100vh - 160rpx);
			background-color: #F3F5F7;
			width: 100vw;

			.img {
				width: 100vw;
				height: 280rpx;
			}

			.no-sign,
			.sign-for {
				margin-top: 14rpx;
			}

			.kupono-confirm,
			.no-sign,
			.sign-for {
				display: flex;
				padding-right: 53rpx;
				padding-left: 42rpx;
				align-items: center;
				width: 750rpx;
				height: 107rpx;
				background: #FFFFFF;
				position: relative;

				.icon {
					width: 51rpx;
					height: 51rpx;

				}

				text {
					margin-left: 18rpx;
					font-family: Source Han Sans CN;
					font-weight: 500;
					font-size: 31rpx;
					color: #333333;

				}

				.arrow {
					position: absolute;
					right: 53rpx;
					top: 50%;
					transform: translateY(-50%);
					width: 15rpx;
					height: 25rpx;

				}

			}

			.data-content {
				padding: 17rpx 28rpx 17rpx 24rpx;

				.bgc {
					width: 100%;
					height: 164rpx;
					background: #FFFFFF;
					border-radius: 21rpx;
					display: flex;
					padding: 0 82rpx;
					justify-content: space-between;
					align-items: center;

					.num,
					.pre-accepted,
					.already-received {
						flex: 1;

						.name {
							text-align: center;
							font-family: Source Han Sans CN;
							font-weight: 400;
							font-size: 23rpx;
							color: #666666;

						}

						.val {
							text-align: center;
							font-family: FZTanHeiS-B-GB;
							font-weight: 400;
							font-size: 35rpx;
							color: #333333;
							margin-top: 2rpx;
						}
					}
				}
			}
		}
	}
</style>